<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root">

    </div>
</body>
<script src="../react.js"></script>
<script src="../react-dom.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
<script type="text/babel">
    console.log(React)
     class App extends React.Component{
              state={
                list:[1,2,3,4,5,6,7]
              }
              render(){
                 let {list} =this.state;
                  return (
                      <div>
                          {
                            list.map((item,index)=>{
                                return <Child key={index} item = {item}/>
                            })
                          }
                          <button onClick={()=>{
                            list[2] =100;
                            this.setState({
                                list:list
                            })
                          }}>修改</button>
                      </div>
                  )
              }
          }
        //   PureComponent 组件类 会自动将 nextProps 和 this.props 做对比 只要发生改变就会渲染 不发生改变就不会发生改变 
         class Child extends React.PureComponent {
                state = {
        
                }
             
                render() {
                    console.log("渲染啦")
                    return (
                        <div>
                           {this.props.item}
                        </div>
                    )
                }
            }
      
          ReactDOM.render(<App/>,document.getElementById("root")) ;
</script>
</html>